package com.ddwl.goods.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.goods.service.BannerService;
import com.ddwl.goods.service.BestSellingService;
import com.ddwl.schema.bo.base.PageBo;
import com.ddwl.schema.bo.goods.BannerBo;
import com.ddwl.schema.bo.goods.BestSellingBo;
import com.ddwl.schema.vo.base.PageVo;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.schema.vo.goods.BannerVo;
import com.ddwl.schema.vo.goods.BestSellingVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "好物购栏目")
@RequestMapping("/bestSelling")
public class BestSellingController extends BaseController {

    @Autowired
    public BestSellingService bestSellingService;

    @PostMapping("/create")
    @ApiOperation("创建横幅修改横幅")
//    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo<String> createdBanner(@RequestBody BestSellingBo bestSellingBo){
        return RestVo.ok(bestSellingService.create(bestSellingBo));
    }

    @GetMapping("/list")
    @ApiOperation("横幅列表")
    public RestVo<List<BestSellingVo>> bannerList(@RequestParam(value = "platform",required = false) Integer platform){
        return RestVo.ok(bestSellingService.bannerList(platform));
    }

    @GetMapping("/detail")
    @ApiOperation("banner详情")
    public RestVo<BestSellingVo> detail(@RequestParam("bannerId") String bannerId){
        return RestVo.ok(bestSellingService.detail(bannerId));
    }

    @PostMapping("/conList")
    @ApiOperation("管理后台列表")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo<PageVo<BestSellingVo>> conList(@RequestBody PageBo<BestSellingBo> pageBo){
        return RestVo.ok(bestSellingService.conList(pageBo));
    }
    @PostMapping("/forbidden")
    @ApiOperation("禁用/开启")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo  forbidden(@RequestBody BestSellingBo bestSellingBo){
        bestSellingService.forbidden(bestSellingBo);
        return RestVo.ok();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo<String> delete(@PathVariable("id")String id){
        return RestVo.ok(bestSellingService.delete(id));
    }

}
